const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  //代理
  devServer: {
    proxy: {
      //api地址代理
      '/api': {
        // 目标 API 地址
        // target: process.env.VUE_APP_BASE_URL,
        // target: 'http://192.168.2.49:8080',
        // target: 'http://39.106.28.24:8081',//测试服，阿里云地址
		target:'http://localhost:8081',
        // 如果要代理 websockets
        // ws: false,
        // 将主机标头的原点更改为目标URL  跨域配置
        changeOrigin: true,
        pathRewrite: {
          '^/api': '',
        },
        secure: false
      }
    }
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('_c', resolve('src/components'))
      .set('_p', resolve('src/pages'))
      .set('_api', resolve('src/http/api'))
      .set('@lib', resolve('src/lib'))
      .set('@img', resolve('src/assets/images'))
  },
  ///less 预处理 less变量的文件名称只能是 variable.less
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [
        path.resolve(__dirname, './src/assets/css/variable.less') // 变量文件位置
      ]
    }
  }
}
